/**
 *
 * @param {String} uploadUrl 附件上传url自己拼接 baseUrl + path
 * @param {Array<String>} files 临时文件url数组
 * @returns
 */
const uploadFile = (uploadUrl, files, formData) => {
  console.log('!!!', formData)
  console.log('uoload执行了', files)
  if (!Array.isArray(files)) {
    console.error('upload:请传入数组')
    return
  }
  const promiseArr = []
  files.forEach((filePath) => {
    console.log('filePath', filePath)
    let params = {
      url: uploadUrl,
      filePath,
      name: 'file',
      formData,
    }
    console.log('params', params)
    const request = uni.uploadFile(params)
    promiseArr.push(request)
  })
  return Promise.all(promiseArr)
}

export default uploadFile
